#==============================================================================
# FIND LINE WITH A SPECIFIC KEYWORD (CASE INSENSITIVE)
#==============================================================================
KeywordFindLine <- function(fs, keyword, env = SetEnv()) { 
	nl <- length(fs)
	keyword <- toupper(keyword) #make case insensitive
	found <- FALSE
	
	for (l in 1:nl) {
		line <- str_trim(fs[l], side = "both") #assign line, but first remove leading/trailing blanks
		if ((substr(line, 1, 1) != env$comchar)*(nchar(line) >= 1)) {
			varname <- unlist(strsplit(line, env$splchar, fixed = TRUE))[1]
			varname <- str_trim(varname, side = "both") #remove blanks
			if ((toupper(varname) == keyword)) {
				found <- TRUE
			}
		}
		if (found == TRUE) break #exit loop if keyword was found
	}	
	
	#return result
	if (found == FALSE) {
		return(NA)
	} else {
		return(l)
	}
}